<template>
  <el-dialog
    v-el-drag-dialog
    :title="title"
    :visible.sync="visible"
    :width="width + 'px'"
    :before-close="onClose"
    @opened="onOpen"
    append-to-body
    :closeOnClickModal="false"
  >
    <div class="containner" :style="{ minHeight: height + 'px' }">
      <slot name="content"></slot>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="onClose()">取 消</el-button>
      <el-button type="primary" :disabled="canConfirm" @click="onConfirm()">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import elDragDialog from '@/directive/el-drag-dialog'
export default {
  directives: { elDragDialog },
  name:"MyDialog",
  props: {
    title: {
      type: String,
      default: "标题",
    },
    visible: {
      type: Boolean,
      default: false,
    },
    width: {
      type: Number,
      default: 700,
    },
    height: {
      type: Number,
      default: 250,
    },
    appendtobody: {
      type: Boolean,
      default: false,
    },
  },
  data(){
    return{
      canConfirm: false
    }
  },
  methods: {
    //关闭事件
    onClose() {
      this.$emit("onClose");
    },
    //确认事件
    onConfirm() {
      this.$emit("onConfirm");
    },
    //打开事件
    onOpen() {
      this.$emit("onOpen");
    }
  },
};
</script>

<style lang="scss" scoped>
.containner{
  overflow-x: initial;
  overflow-y: auto;
  max-height: 60vh;
}
.el-dialog__wrapper {
  ::v-deep .el-dialog {
    margin-top: 10vh !important;
    border-radius: 4px;
    .el-dialog__header {
      .el-dialog__title {
        letter-spacing: 2px;
        font-size: 16px;
        font-weight: bolder;
      }
    }
    .el-dialog__body {
      padding: 20px;
      border: 1px solid #dfe6ec !important;
      border-left: none;
      border-right: none;
    }
    .el-dialog__footer {
      padding: 10px;
    }
  }
}
</style>
